package com.tiyende.kash.loop.utils.helper

import android.Manifest
import com.lib.common.permission.Permission
import com.tiyende.kash.loop.R
import com.tiyende.kash.loop.TiyendeApp
import org.json.JSONArray
import org.json.JSONObject

object TiyendePermissionHelper {

    /**
     * sms
     */
    fun queryTiyendeMSAGItem(): JSONObject {
        val item = JSONObject()
        item.put("isSystem",true)
        item.put("permission", Manifest.permission.READ_SMS)
        item.put("title", TiyendeApp.app.getString(R.string.tiyende_permission_sms_title))
        val msgArray = JSONArray()
        val obj1 = JSONObject()
        obj1.put("title", TiyendeApp.app.getString(R.string.tiyende_permission_sms_what))
        obj1.put("des", TiyendeApp.app.getString(R.string.tiyende_permission_sms_what_reason))
        msgArray.put(obj1)

        val obj2 = JSONObject()
        obj2.put("title", TiyendeApp.app.getString(R.string.tiyende_permission_sms_why))
        obj2.put("des", TiyendeApp.app.getString(R.string.tiyende_permission_sms_why_reason))
        msgArray.put(obj2)

        val obj3 = JSONObject()
        obj3.put("title", TiyendeApp.app.getString(R.string.tiyende_permission_sms_data_security))
        obj3.put("des", TiyendeApp.app.getString(R.string.tiyende_permission_sms_data_security_reason))
        msgArray.put(obj3)
        item.put("msgList",msgArray)
        return item
    }

    /**
     * phone state
     */
    fun queryTiyendePhoneStateItem(): JSONObject {
        val item = JSONObject()
        item.put("isSystem",false)
        item.put("permission", TiyendeApp.app.getString(R.string.tiyende_permission_phone_state_title))
        item.put("title", TiyendeApp.app.getString(R.string.tiyende_permission_phone_state_title))
        val msgArray = JSONArray()
        val obj1 = JSONObject()
        obj1.put("title", "")
        obj1.put("des", TiyendeApp.app.getString(R.string.tiyende_permission_phone_state_reason1))
        msgArray.put(obj1)

        val obj2 = JSONObject()
        obj2.put("title", "")
        obj2.put("des", TiyendeApp.app.getString(R.string.tiyende_permission_phone_state_reason2))
        msgArray.put(obj2)

        val obj3 = JSONObject()
        obj3.put("title", "")
        obj3.put("des", TiyendeApp.app.getString(R.string.tiyende_permission_phone_state_reason3))
        msgArray.put(obj3)

        val obj4 = JSONObject()
        obj4.put("title", "")
        obj4.put("des", TiyendeApp.app.getString(R.string.tiyende_permission_phone_state_reason4))
        msgArray.put(obj4)
        item.put("msgList",msgArray)
        return item
    }

    /**
     * app list
     */
    fun queryTiyendeAPListItem(): JSONObject {
        val item = JSONObject()
        item.put("isSystem",false)
        item.put("permission",TiyendeApp.app.getString(R.string.tiyende_permission_app_list_title))
        item.put("title", TiyendeApp.app.getString(R.string.tiyende_permission_app_list_title))
        val msgArray = JSONArray()
        val obj1 = JSONObject()
        obj1.put("title", TiyendeApp.app.getString(R.string.tiyende_permission_app_list_why))
        obj1.put("des", TiyendeApp.app.getString(R.string.tiyende_permission_app_list_why_reason))
        msgArray.put(obj1)

        val obj2 = JSONObject()
        obj2.put("title", TiyendeApp.app.getString(R.string.tiyende_permission_app_list_do))
        obj2.put("des", TiyendeApp.app.getString(R.string.tiyende_permission_app_list_do_reason))
        msgArray.put(obj2)

        val obj3 = JSONObject()
        obj3.put("title",  TiyendeApp.app.getString(R.string.tiyende_permission_app_list_collect))
        obj3.put("des", TiyendeApp.app.getString(R.string.tiyende_permission_app_list_collect_reason))
        msgArray.put(obj3)

        val obj4 = JSONObject()
        obj4.put("title",  TiyendeApp.app.getString(R.string.tiyende_permission_app_list_data_safety))
        obj4.put("des", TiyendeApp.app.getString(R.string.tiyende_permission_app_list_data_safety_reason))
        msgArray.put(obj4)
        item.put("msgList",msgArray)
        return item
    }

    /**
     * camera
     */
    fun queryTiyendeCameraItem(): JSONObject {
        val item = JSONObject()
        item.put("isSystem",false)
        item.put("permission", Permission.CAMERA)
        item.put("title", TiyendeApp.app.getString(R.string.tiyende_permission_camera_title))
        item.put("icon",R.mipmap.tiyende_permission_phone_state_icon)
        val msgArray = JSONArray()
        val obj1 = JSONObject()
        obj1.put("title", "")
        obj1.put("des", TiyendeApp.app.getString(R.string.tiyende_permission_camera_reason1))
        msgArray.put(obj1)

        val obj2 = JSONObject()
        obj2.put("title", "")
        obj2.put("des", TiyendeApp.app.getString(R.string.tiyende_permission_camera_reason2))
        msgArray.put(obj2)

        val obj3 = JSONObject()
        obj3.put("title", "")
        obj3.put("des", TiyendeApp.app.getString(R.string.tiyende_permission_camera_reason3))
        msgArray.put(obj3)
        item.put("msgList",msgArray)
        return item
    }

    /**
     * album
     */
    fun queryTiyendePhotoAlbumItem(): JSONObject {
        val item = JSONObject()
        item.put("isSystem",false)
        item.put("permission", TiyendeApp.app.getString(R.string.tiyende_permission_album_title))
        item.put("title", TiyendeApp.app.getString(R.string.tiyende_permission_album_title))
        val msgArray = JSONArray()
        val obj1 = JSONObject()
        obj1.put("title", "")
        obj1.put("des", TiyendeApp.app.getString(R.string.tiyende_permission_album_reason1))
        msgArray.put(obj1)

        val obj2 = JSONObject()
        obj2.put("title", "")
        obj2.put("des", TiyendeApp.app.getString(R.string.tiyende_permission_album_reason2))
        msgArray.put(obj2)
        item.put("msgList",msgArray)
        return item
    }

    /**
     * address book
     */
    fun queryTiyendeAddressBookItem(): JSONObject {
        val item = JSONObject()
        item.put("isSystem",false)
        item.put("permission", TiyendeApp.app.getString(R.string.tiyende_permission_address_book_title))
        item.put("title", TiyendeApp.app.getString(R.string.tiyende_permission_address_book_title))
        val msgArray = JSONArray()
        val obj1 = JSONObject()
        obj1.put("title", "")
        obj1.put("des", TiyendeApp.app.getString(R.string.tiyende_permission_address_book_reason1))
        msgArray.put(obj1)

        val obj2 = JSONObject()
        obj2.put("title", "")
        obj2.put("des", TiyendeApp.app.getString(R.string.tiyende_permission_address_book_reason2))
        msgArray.put(obj2)
        item.put("msgList",msgArray)
        return item
    }

    /**
     * storage
     */
    fun queryTiyendeStorageItem(): JSONObject {
        val item = JSONObject()
        item.put("isSystem",false)
        item.put("permission", TiyendeApp.app.getString(R.string.tiyende_permission_storage_title))
        item.put("title", TiyendeApp.app.getString(R.string.tiyende_permission_storage_title))
        val msgArray = JSONArray()
        val obj1 = JSONObject()
        obj1.put("title", "")
        obj1.put("des", TiyendeApp.app.getString(R.string.tiyende_permission_storage_reason1))
        msgArray.put(obj1)

        val obj2 = JSONObject()
        obj2.put("title", "")
        obj2.put("des", TiyendeApp.app.getString(R.string.tiyende_permission_storage_reason2))
        msgArray.put(obj2)

        val obj3 = JSONObject()
        obj3.put("title", "")
        obj3.put("des", TiyendeApp.app.getString(R.string.tiyende_permission_storage_reason3))
        msgArray.put(obj3)
        item.put("msgList",msgArray)
        return item
    }
}